<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>检查单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">

<!-- 查询条件开始-->
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form" method="post" id="searchFrm">
            <div class="layui-form-item">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">检查单号:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="checkid"     autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">出租单号:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="rentid"     autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">存在问题:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="problem"   autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">开始时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="startTime" id="startTime" readonly="readonly"   autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">结束时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="endTime" id="endTime"  readonly="readonly"  autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">问题描述:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="checkdesc"   autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div  class="layui-form-item" style="text-align: center;">
                <div class="layui-input-block" >
                    <button type="button" class="layui-btn layui-btn-normal  layui-icon layui-icon-search" lay-submit lay-filter="doSearch">查询</button>
                    <button type="reset" class="layui-btn layui-btn-warm  layui-icon layui-icon-refresh">重置</button>
                </div>
            </div>
        </form>
    </blockquote>
</form>
<!-- 查询条件结束-->

<!-- 数据表格开始 -->
<table class="layui-hide" id="checkTable" lay-filter="checkTable"></table>
<div style="display: none;" id="checkToolBar"></div>
<div style="display: none;"  id="checkRowBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</div>
<!-- 数据表格结束 -->

<!-- 添加和修改的弹出层开始 -->
<div style="display: none;padding: 20px" id="addOrUpdateDiv" >
    <form class="layui-form"  lay-filter="dataFrm" id="dataFrm">
        <!-- 隐藏域 -->
        <input type="hidden" name="id" >
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">检查时间:</label>
                <div class="layui-input-inline">
                    <input type="text" name="checkdate"  id="checkdate" readonly="readonly" placeholder="请输入起租时间"  autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">操作员:</label>
                <div class="layui-input-inline">
                    <input type="text" name="opername" lay-verify="required"  readonly="readonly" placeholder="请输入操作员" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">检查单号:</label>
            <div class="layui-input-block">
                <input type="text" name="checkid"  id="checkid" readonly="readonly" placeholder="请输入检查单号"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">出租单号:</label>
            <div class="layui-input-block">
                <input type="text" name="rentid" lay-verify="required"  readonly="readonly"  placeholder="请输入出租单号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">赔付金额:</label>
                <div class="layui-input-inline">
                    <input type="text" name="paymoney" lay-verify="required"   placeholder="请输入车牌号" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">问题描述:</label>
                <div class="layui-input-inline">
                    <input type="text" name="checkdesc" lay-verify="required"   placeholder="请输入问题描述" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">存在问题:</label>
            <div class="layui-input-block">
                <input type="text" name="problem" lay-verify="required"   placeholder="请输入身份证号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="text-align: center;">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-icon layui-icon-release" lay-filter="doSubmit" lay-submit="">提交</button>
                <button type="reset" class="layui-btn layui-btn-warm layui-btn-sm layui-icon layui-icon-refresh" >重置</button>
            </div>
        </div>
    </form>

</div>
<!-- 添加和修改的弹出层结束 -->
<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery','form','table','layer','upload','laydate'],function () {
        var $=layui.jquery;
        var form=layui.form;
        var table=layui.table;
        var layer=layui.layer;
        var upload=layui.upload;
        var laydate=layui.laydate;


//渲染数据表格
        var tableIns = table.render({
            elem: '#checkTable'
            ,url:'/bus/check/list'
            ,toolbar: '#checkToolBar' //开启头部工具栏，并为其绑定左侧模板
            ,page: true
            ,height:"full-180"
            ,title: '检查单数据表'
            ,cols: [ [
                {field:'id', title:'编号',align:'center',width:'80'}
                ,{field:'checkid', title:'检查单号',align:'center',width:'260'}
                ,{field:'rentid', title:'出租单号',align:'center',width:'260'}
                ,{field:'checkdate', title:'检查时间',align:'center',width:'180'}
                ,{field:'problem', title:'存在问题',align:'center',width:'180'}
                ,{field:'checkdesc', title:'问题描述',align:'center',width:'180'}
                ,{field:'paymoney', title:'赔付金额',align:'center',width:'120'}
                ,{field:'opername', title:'操作员',align:'center',width:'120'}
                ,{field:'createtime', title:'录入时间',align:'center',width:'180'}
                ,{fixed: 'right', title:'操作', toolbar: '#checkRowBar', width:100,align:'center'}
            ] ],
            done:function (res,curr,count) {
                //判断当前页码是否是大于1并且当前页的数据量为0
                if(curr>1 && res.data.length==0){
                    var pageValue = curr -1;
                    //刷新数据表格的数据
                    tableIns.reload({
                        page:{curr:pageValue}
                    });
                }
            }
        });

        //监听表单提交事件
        form.on("submit(doSearch)",function (data) {
            tableIns.reload({
                url:'/bus/check/list',
                where:data.field,
                page:{
                    curr:1
                }
            });
            return false;
        });


        //监听行工具栏事件
        table.on('tool(checkTable)',function (obj) {
            switch (obj.event) {
                case 'edit':
                    //打开头部工具栏添加公告的窗口
                    openUpdateCheck(obj.data);
                    break;
            }
        })


        var mainIndex;//打开窗口的索引
        var url;//提交请求的地址

        function openUpdateCheck(data) {
            mainIndex = layer.open({
                type: 1,
                content: $('#addOrUpdateDiv'),
                area: ["800px", "500px"],
                title: "修改检查单",
                success: function () {
                    //每次打开窗口，清空表单数据
                    form.val("dataFrm", data);
                    //提交数据
                    url = "/bus/check/updataCheck";
                }
            });
        }



        //监听表单提交事件
        form.on("submit(doSubmit)",function (data) {
            $.post(url, data.field, function (result) {
                if (result.success){
                    //提示信息
                    layer.msg(result.message,{icon:1})

                    tableIns.reload();

                    layer.close(mainIndex);

                }else {
                    layer.msg(result.message,{icon:2});
                }
            }, "json");
            //禁止页面跳转
            return false;
        })

    });
</script>
</body>

</html>